<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/templateNotAlerta.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Cadastrar novo Compromisso/Agenda</a></h2><br/>
	
            <h:form id="agendaForm">
            
	           <h:panelGrid columns="1">
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Data:</ui:define>
	            		<rich:calendar value="#{manterAgendaController.agendaEdicao.dtaAgenda}"
	            			enableManualInput="true"
	            			oninputkeydown="Mascara(this,Data)"
	            			oninputkeyup="Mascara(this,Data)"
	            			datePattern="dd/MM/yyyy"
	            			required="true"
	            			showWeekDaysBar="false"/>
	            			
	            		<h:inputText value="#{manterAgendaController.horaEdicao}" maxlength="2"
	            			size="4"
	            			required="true"
	            			onkeydown="Mascara(this,Integer)"
	            			onkeyup="Mascara(this,Integer)"/>
	            			:
	            		<h:inputText value="#{manterAgendaController.minutoEdicao}" maxlength="2"
	            			size="4"
	            			required="true"
	            			onkeydown="Mascara(this,Integer)"
	            			onkeyup="Mascara(this,Integer)"/>
	            	</s:decorate>
	           </h:panelGrid>
	           <h:panelGrid columns="1" id="gridRecursivo"> 	
	            	<s:decorate template="/layout/edit.xhtml" rendered="#{usuarioLogado == null or usuarioLogado.cliente == null}">
	            		<ui:define name="label">Recursivo?</ui:define>
	            		<h:selectOneRadio value="#{manterAgendaController.agendaEdicao.flgRecursivo}"
	            			required="#{usuarioLogado == null or usuarioLogado.cliente == null}"
	            			valueChangeListener="#{manterAgendaController.selecionaFlgRecursivoListener}">
	            			<f:selectItem itemLabel="SIM" itemValue="true"/>
	            			<f:selectItem itemLabel="NÃO" itemValue="false"/>
	            			<a:support event="onchange" ajaxSingle="true" reRender="gridRecursivo"/>
	            		</h:selectOneRadio>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml" rendered="#{manterAgendaController.agendaEdicao.flgRecursivo != null and manterAgendaController.agendaEdicao.flgRecursivo}">
	            		<ui:define name="label">Quantidade de dias:</ui:define>
	            		<h:inputText value="#{manterAgendaController.agendaEdicao.qtdDiasRecursao}"
	            			maxlength="2"
	            			size="5" 
	            			onkeydown="Mascara(this,Integer)"
	            			onkeyup="Mascara(this,Integer)"
	            			required="true"/>
	            	</s:decorate>
	            </h:panelGrid>
	            <h:panelGrid columns="1">	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Título:</ui:define>
	            		<h:inputText value="#{manterAgendaController.agendaEdicao.dscTitulo}" 
	            			maxlength="30"
	            			required="true"
	            			size="60"/>
	            	</s:decorate>
	            	
	            	<s:decorate template="/layout/edit.xhtml">
	            		<ui:define name="label">Descrição:</ui:define>
	            		<h:inputTextarea value="#{manterAgendaController.agendaEdicao.dscAgenda}" 
	            			rows="5"
	            			required="true"
	            			cols="70">
	            			<f:validateLength maximum="300"/>
	            		</h:inputTextarea>
	            	</s:decorate>
	            </h:panelGrid>
	            <br/>
	            <div class="actionButtons">
		        	<h:commandButton id="submit" value="Salvar" action="#{manterAgendaController.salvar}"
		            	onclick="javascript:if(!confirm('Tem certeza que deseja salvar?'))return false;#{rich:component('carregando')}.show()"/>
		            	
		            <h:commandButton id="remove" value="Excluir" action="#{manterAgendaController.excluir(manterAgendaController.agendaEdicao)}"
		            	rendered="#{manterAgendaController.agendaEdicao.idAgenda != null and identity.hasRole('GERENCIAR_AGENDA_EXCLUIR')}"
		            	onclick="javascript:if(!confirm('Tem certeza que deseja excluir a agenda?'))return false;"/>
		            
		            <a:commandButton id="voltar" value="Voltar" 
		        		action="#{manterAgendaController.voltar()}" 
		        		ajaxSingle="true"/>
		        </div>
				<br/>
				
			</h:form>
			
 </ui:define>
</ui:composition>
